package com.zed.api.useradmin;

/**
 * 登录凭证已经被他人使用时抛出的例外
 *
 * @author Zed
 */
public class LoginCertificateUsedException extends AccountException {

    /**
     *
     */
    private static final long serialVersionUID = -7815581588482218174L;

    private LoginCertificate certificate;

    /**
     *
     */
    public LoginCertificateUsedException(LoginCertificate certificate) {
        super("login certificate is exists: domain=" + certificate.getDomain() + ", identifier=" + certificate.getIdentifier());
        this.certificate = certificate;
    }

    /**
     * 获取登录凭证
     *
     * @return {@link LoginCertificate}
     */
    public LoginCertificate getLoginCertificate() {
        return this.certificate;
    }

    @Override
    public String getLocalizedMessage() {
        return String.format("登录凭证已经使用[域=%s, 编号=%s]", this.getLoginCertificate().getDomain(), this.getLoginCertificate().getIdentifier());
    }
}
